<?php


namespace app\superadmin\model;


use think\Model;

class User extends Model
{

    public function mb_Add($Name, $Nick, $BasePass, $Level, $WeChat, $QQ, $Phone, $Email, $Sex, $Remark)
    {
        if(self::where('Name',$Name)->find() == null){
            $Data = array(
                'Name' => $Name,
                'Nick' => $Nick,
                'BasePass' => $BasePass,
                'EncPass' => md5($BasePass),
                'Level' => $Level,
                'WeChat' => $WeChat,
                'QQ' => $QQ,
                'Phone' => $Phone,
                'Sex' => $Sex,
                'Remark' => $Remark
            );
            self::save($Data);
            return true;
        } else {
            return false;
        }
    }

    public function mb_Update($Data){
        // if(self::where($KeyName, $KeyVal)->find() == null){
        //     return false;
        // } else {
        //     self::save($Data);
        //     return true;
        // }
        self::save($Data);
    }

    public function mb_Delete($KeyName, $KeyVal){
        if(self::where($KeyName, $KeyVal)->find() == null){
            return false;
        } else {
            self::where($KeyName, $KeyVal)->delete();
            return true;
        }
    }

    public function mb_Get($Where){
        return self::where($Where)->find();
    }


    public function mb_List($Where, $LimitIndex, $LimitCount, $OrderKey, $OrderType){
        return self::where($Where)->limit($LimitIndex, $LimitCount)->order($OrderKey, $OrderType)->select();
    }
}